Implement foreach on lvref lexical without magic#24202
Open
leonerd wants to merge 2 commits intoPerl:bleadfrom
Open
Implement foreach on lvref lexical without magic#24202leonerd wants to merge 2 commits intoPerl:bleadfrom
foreach on lvref lexical without magic#24202leonerd wants to merge 2 commits intoPerl:bleadfrom
Conversation
The previous giant list was too big to debug if a single test case happened to fail
Previously, commit 091a08d made a more efficient implemention of `foreach` loops where the iteration variable was declared using `\my $VAR`. A cornercase of that logic was missed, wherein the iteration variable was *previously* declared as a lexical before the foreach loop itself. That resulted in an optree using `OP_SREFGEN` on `OP_LVREF` directly, rather than on a `OP_PADxV`, so a case was missed. By covering this case here as well, we now manage to remove any uses of `PERL_MAGIC_lvref` to implement `foreach` loops on refaliased lexicals. The code to implement those now-dead cases has been removed and replaced with an `assert(mg->mg_obj)`, to cover the still-remaining case of iteration over a refalias to a package variable. Those may be covered in a later commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, commit 091a08d made a more efficient implemention of
foreachloops where the iteration variable was declared using\my $VAR. A cornercase of that logic was missed, wherein the iteration variable was previously declared as a lexical before the foreach loop itself. That resulted in an optree usingOP_SREFGENonOP_LVREFdirectly, rather than on aOP_PADxV, so a case was missed.By covering this case here as well, we now manage to remove any uses of
PERL_MAGIC_lvrefto implementforeachloops on refaliased lexicals. The code to implement those now-dead cases has been removed and replaced with anassert(mg->mg_obj), to cover the still-remaining case of iteration over a refalias to a package variable. Those may be covered in a later commit.